@import './_color.scss';
@import './comment.scss';
@import './list.scss';
@import './pagination.scss';
@import './editor.scss';
@import './sidebar-layer.scss';

.artalk {
  position: relative;
  width: 100%;
  min-height: 200px;
}

.artalk,
.atk-layer-wrap {
  color: var(--at-color-font);
  word-wrap: break-word;
  word-break: break-word;

  * {
    box-sizing: border-box;
  }

  input,
  textarea,
  button,
  optgroup,
  select {
    font-family: inherit;
    color: inherit;
    font-size: inherit;
  }

  $codeFont:
    source code pro,
    Consolas,
    Monaco,
    Menlo,
    sans-serif;

  code {
    font-family: $codeFont;
    margin: 0 0.05em;
    padding: 0 0.4em;
    display: inline-block;
    vertical-align: middle;
    font-size: 0.9em;
    background-color: var(--at-color-bg-grey);
    color: var(--at-color-font);
    border-radius: 2px;
  }

  pre {
    margin: 10px 0 0 0;
    padding: 0;
    line-height: 0;
  }

  pre code {
    * {
      font-family: $codeFont;
    }
    line-height: $line-height;
    display: block;
    padding: 10px 15px;
    white-space: pre-wrap !important;
    background-color: var(--at-color-bg-grey);
    color: var(--at-color-font);
    margin: 0;
  }

  a {
    color: var(--at-color-main);
    text-decoration: none;
  }

  blockquote {
    position: static;
    margin: 10px 0 10px 0;
    padding: 10px 20px 10px 20px;
    background: var(--at-color-bg-grey);
    border-left: 4px solid #687a86;
    color: var(--at-color-font);
  }

  p:first-child {
    margin-top: 0;
  }

  p:last-child {
    margin-bottom: 0;
  }

  img {
    max-width: 100%;
  }

  table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    margin-bottom: 1.5em;
    font-size: 0.96em;
  }

  td,
  th {
    text-align: left;
    padding: 4px 8px 4px 10px;
    border: 1px solid var(--at-color-border);
  }

  td {
    vertical-align: top;
  }

  tr:nth-child(even) {
    background-color: var(--at-color-bg-grey);
  }

  ul {
    list-style: disc;
  }

  ol {
    list-style: decimal;
  }

  li + li {
    margin-top: 8px;
  }

  li > ol,
  li > ul {
    margin: 8px 0 0;
  }
}

.atk-hide {
  display: none !important;
}

.atk-full-layer {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  background: var(--at-color-bg);
  z-index: 4;
  align-items: center;
  justify-content: center;
  flex-flow: column;
  display: flex;
}

/* Loading */
.atk-loading {
  @extend .atk-full-layer;
}

.atk-loading-spinner {
  position: relative;
  width: 50px;
  height: 50px;

  svg {
    animation: atkRotate 2s linear infinite;
    transform-origin: center center;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;

    circle {
      stroke-dasharray: 1, 200;
      stroke-dashoffset: 0;
      animation:
        atkDash 1.5s ease-in-out infinite,
        atkColor 6s ease-in-out infinite;
      stroke-linecap: round;
    }
  }
}

@keyframes atkRotate {
  100% {
    transform: rotate(360deg);
  }
}

@keyframes atkDash {
  0% {
    stroke-dasharray: 1, 200;
    stroke-dashoffset: 0;
  }

  50% {
    stroke-dasharray: 89, 200;
    stroke-dashoffset: -35px;
  }

  100% {
    stroke-dasharray: 89, 200;
    stroke-dashoffset: -124px;
  }
}

@keyframes atkColor {
  0%,
  100% {
    stroke: #ff5652;
  }
  40% {
    stroke: #2196f3;
  }
  66% {
    stroke: #32c787;
  }
  80%,
  90% {
    stroke: #ffc107;
  }
}

@keyframes atkLoadingIconRotate {
  0% {
    transform: rotate(0);
  }
  100% {
    transform: rotate(360deg);
  }
}

.atk-loading-icon {
  width: 18px;
  height: 18px;
  box-sizing: border-box;
  border: solid 1px transparent;
  border-top-color: #29d;
  border-left-color: #29d;
  border-radius: 50%;
  animation: atkLoadingIconRotate 0.4s linear infinite;
}

/* Animations */
.atk-fade-in {
  animation: atkFadeIn both 0.3s;
}

.atk-fade-out {
  animation: atkFadeOut both 0.2s;
}
.atk-rotate {
  animation: atkRotate 2s linear infinite;
}

@keyframes atkFadeIn {
  0% {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes atkFadeOut {
  100% {
    opacity: 0;
  }
  0% {
  }
}

@keyframes atkRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.atk-icon {
  &::after {
    display: block;
    content: '';
    width: 1em;
    height: 1em;
    background-color: var(--at-color-deep);
    background-size: contain;
    background-repeat: no-repeat;
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
  }
}

.atk-icon-sync::after {
  mask-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4.99133 4.87635C2.22512 7.64257 2.22512 12.1275 4.99133 14.8937C6.04677 15.9491 7.3524 16.6019 8.71732 16.8519' stroke='%234E5969' stroke-width='2'/%3E%3Cpath d='M14.4179 15.4815L15.0072 14.8922C17.7734 12.126 17.7734 7.64107 15.0072 4.87486C13.9518 3.81942 12.6461 3.16668 11.2812 2.91664' stroke='%234E5969' stroke-width='2'/%3E%3Cpath d='M6.17106 4.99252L5.58181 4.40327L4.99255 3.81401H6.17106V4.99252Z' fill='%23C4C4C4' stroke='%234E5969' stroke-width='2'/%3E%3Cpath d='M13.8299 15.0084L14.4192 15.5976L15.0084 16.1869H13.8299V15.0084Z' fill='%23C4C4C4' stroke='%234E5969' stroke-width='2'/%3E%3C/svg%3E");
}

.atk-icon-del::after {
  background-color: var(--at-color-red) !important;
  mask-image: url("data:image/svg+xml,%3Csvg width='22' height='22' viewBox='0 0 22 22' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2.29167 5.04166L4.81251 5.04166M4.81251 5.04166L4.81251 18.3333C4.81251 18.5865 5.01771 18.7917 5.27084 18.7917L16.7292 18.7917C16.9823 18.7917 17.1875 18.5865 17.1875 18.3333V5.04166M4.81251 5.04166L7.33334 5.04166M17.1875 5.04166L19.7083 5.04166M17.1875 5.04166L14.6667 5.04166M7.33334 5.04166V3.20833L14.6667 3.20833V5.04166M7.33334 5.04166L14.6667 5.04166' stroke='%23D06565' stroke-width='2'/%3E%3Cpath d='M9.16667 8.25V15.125M12.8333 8.25V15.125' stroke='%23D06565' stroke-width='2'/%3E%3C/svg%3E");
}

.atk-icon-edit::after {
  mask-image: url("data:image/svg+xml,%3Csvg width='16' height='17' viewBox='0 0 16 17' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M9.70618 4.08515L12.6081 7.06376M1.00041 13.021L11.7376 2L14.6392 4.97861L3.90274 16H1L1.00041 13.021Z' stroke='%234E5969' stroke-width='1.5'/%3E%3C/svg%3E");
}

.atk-icon-yes::after,
.atk-icon-check::after {
  mask-image: url("data:image/svg+xml,%3Csvg width='25' height='25' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M21.7071 5.75533L9.92197 17.5404L3.29285 10.9113' stroke='%234E5969'/%3E%3C/svg%3E");
}

.atk-icon-plus::after {
  mask-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2.08331 10H17.9166' stroke='%234E5969' stroke-width='2'/%3E%3Cpath d='M10 2.08334L10 17.9167' stroke='%234E5969' stroke-width='2'/%3E%3C/svg%3E");
}

.atk-icon-close-slim::after {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='25' height='25' viewBox='0 0 25 25' fill='none'%3E%3Cpath d='M19.8657 5.13431L12.5 12.5L5.13431 19.8657' stroke='%234E5969'/%3E%3Cpath d='M5.13431 5.13432L12.5 12.5L19.8657 19.8657' stroke='%234E5969'/%3E%3C/svg%3E");
}

.atk-icon-arrow-left::after {
  mask-image: url('data:image/svg+xml,<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M6.54542 8.00004L11 12.6667L9.72729 14L4 8.00004L9.72729 2L11 3.33333L6.54542 8.00004Z" /></svg>');
}

.atk-icon-no::after,
.atk-icon-close::after {
  mask-image: url('data:image/svg+xml,<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 512 512" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M405 136.798L375.202 107 256 226.202 136.798 107 107 136.798 226.202 256 107 375.202 136.798 405 256 285.798 375.202 405 405 375.202 285.798 256z"></path></svg>');
}

/* Layer */
.atk-error-layer {
  @extend .atk-full-layer;
  background-color: var(--at-color-bg-transl);

  .atk-error-title {
    color: var(--at-color-red);
  }

  .atk-warn-title {
    color: var(--at-color-yellow);
  }

  .atk-error-title,
  .atk-warn-title {
    display: inline-block;
    padding: 0 15px;
    margin-bottom: 20px;
    font-size: 20px;
    letter-spacing: -0.5px;
  }

  .atk-error-text {
    text-align: center;
    padding: 0 20px;

    * {
      color: var(--at-color-deep);
    }

    a {
      color: var(--at-color-meta);
    }
  }
}

.atk-version-check-notice {
  background: var(--at-color-bg-grey);
  border-radius: $block-radius;
  padding: 10px 20px;
  margin-bottom: 10px;
  font-size: 14px;

  .atk-info {
    color: var(--at-color-meta);
  }

  .atk-ignore-btn {
    cursor: pointer;
    float: right;

    &:hover {
      opacity: 0.8;
    }
  }
}

.atk-layer-dialog-wrap {
  $formInputHeight: 30px;
  @extend .atk-full-layer;
  background-color: var(--at-color-bg-transl);

  & > .atk-layer-dialog {
    width: 25%;

    & > .atk-layer-dialog-content {
      .atk-captcha-img {
        cursor: pointer;
        width: 170px;
        height: auto;
        margin-right: 10px;
        padding-right: 10px;
        border-right: 1px solid var(--at-color-border);
        vertical-align: bottom;
      }

      input {
        width: 100%;
        line-height: calc($formInputHeight + 4px);
        background-color: var(--at-color-bg);
        border: 1px solid var(--at-color-border);
        border-radius: calc($block-radius / 2);
        outline: none;
        padding: 0 6px;
        display: block;
        margin-top: 10px;
        margin-bottom: 5px;
        text-align: center;
      }
    }

    & > .atk-layer-dialog-actions {
      display: flex;
      flex-direction: row;

      button {
        flex: 1;
        display: block;
        cursor: pointer;
        border: 1px solid var(--at-color-main);
        background: transparent;
        color: var(--at-color-main);
        border-radius: calc($block-radius / 2);
        padding: 0 15px;
        line-height: $formInputHeight;
        outline: none;

        &:active {
          color: #fff;
          background: var(--at-color-main);
        }

        &:not(:last-child) {
          margin-right: 5px;
        }

        &.error {
          color: #fff;
          background: #ff5652;
          border-color: #ff5652;
        }
      }
    }

    .atk-checker-iframe-wrap {
      position: fixed;
      z-index: 999998;
      left: 0;
      top: 0;
      height: 100vh;
      width: 100vw;

      & > iframe {
        width: 100%;
        height: 100%;
        border: 0;
      }

      .atk-close-btn {
        z-index: 999999;
        position: fixed;
        top: 20px;
        right: 20px;
        display: flex;
        flex-direction: column;
        width: 50px;
        height: 50px;
        align-items: center;
        place-content: center;
        cursor: pointer;
        user-select: none;
        margin-left: 10px;

        &:hover .atk-icon-close::after {
          background-color: rgba(232, 17, 35, 0.9);
        }
      }
    }
  }
}

@media only screen and (max-width: 768px) {
  .atk-layer-dialog-wrap > .atk-layer-dialog {
    width: 90% !important;
  }
}

.atk-notify {
  display: block;
  overflow: hidden;
  background-color: #2c2c2c;
  color: #fff;
  border-radius: calc($block-radius / 2);
  cursor: pointer;
  font-size: 14px;
  padding: 5px 15px;

  &:not(:last-child) {
    margin-bottom: 3px;
  }

  .atk-notify-content {
    color: #fff;
  }
}

.atk-layer-wrap {
  .atk-layer-mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99998;
    background: rgba(0, 0, 0, 0.3);
  }

  .atk-layer-item {
    position: fixed;
    z-index: 99999;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
  }
}

/* Common Action Btn */
.atk-common-action-btn {
  &.atk-btn-confirm {
    color: var(--at-color-yellow) !important;
  }

  &.atk-btn-warn {
    color: var(--at-color-yellow) !important;
  }

  &.atk-btn-error {
    color: var(--at-color-red) !important;
  }

  &.atk-btn-success {
    color: var(--at-color-green) !important;
  }
}

img[atk-emoticon] {
  max-height: 60px;
  display: initial;
}
